﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace RiskMan.DataClass.AlfaDirectFolder
{
    /// <summary>
    /// ТАБЛИЦА «ALL_TRADES» - ТЕКУЩИЕ СДЕЛКИ НА РЫНКЕ
    /// Ключевое поле: trd_no
    /// </summary>
    class AllTrades : INotifyPropertyChanged
    {
        #region Private

        private int _trdNo;
        private int _paperNo;
        private int _qty;
        private double _price;
        private string _tsTime;
        private int _iLastUpdate;
        private int _change;
        private int _type;
        private string _pCode;
        private string _placeCode;
        private string _ansiName;
        private string _placeName;
        private string _typeDescr;

        #endregion

        #region Public

        /// <summary>
        /// Номер сделки на бирже.
        /// </summary>
        public int TrdNo
        {
            get { return _trdNo; }
            set
            {
                if (_trdNo != value)
                    _trdNo = value;

                RaisePropertyChanged("TrdNo");
            }
        }
        /// <summary>
        /// Цифровой код финансового инструмента.
        /// </summary>
        public int PaperNo
        {
            get { return _paperNo; }
            set
            {
                if (_paperNo != value)
                    _paperNo = value;

                RaisePropertyChanged("PaperNo");
            }
        }
        /// <summary>
        /// Количество.
        /// </summary>
        public int Qty
        {
            get { return _qty; }
            set
            {
                if (_qty != value)
                    _qty = value;

                RaisePropertyChanged("Qty");
            }
        }
        /// <summary>
        /// Цена.
        /// </summary>
        public double Price
        {
            get { return _price; }
            set
            {
                if (_price != value)
                    _price = value;

                RaisePropertyChanged("Price");
            }
        }
        /// <summary>
        /// Время торговой системы.
        /// </summary>
        public string TsTime
        {
            get { return _tsTime; }
            set
            {
                if (_tsTime != value)
                    _tsTime = value;

                RaisePropertyChanged("TsTime");
            }
        }
        /// <summary>
        /// Временная метка последнего обновления.
        /// </summary>
        public int ILastUpdate
        {
            get { return _iLastUpdate; }
            set
            {
                if (_iLastUpdate != value)
                    _iLastUpdate = value;

                RaisePropertyChanged("ILastUpdate");
            }
        }
        /// <summary>
        /// Направление изменения цены.
        /// </summary>
        public int Change
        {
            get { return _change; }
            set
            {
                if (_change != value)
                    _change = value;

                RaisePropertyChanged("Change");
            }
        }
        /// <summary>
        /// Тип (внешний ключ таблицы trade_types).
        /// </summary>
        public int Type
        {
            get { return _type; }
            set
            {
                if (_type != value)
                    _type = value;

                RaisePropertyChanged("Type");
            }
        }
        /// <summary>
        /// Код актива.
        /// </summary>
        public string PCode
        {
            get { return _pCode; }
            set
            {
                if (_pCode != value)
                    _pCode = value;

                RaisePropertyChanged("PCode");
            }
        }
        /// <summary>
        /// Код рынка.
        /// </summary>
        public string PlaceCode
        {
            get { return _placeCode; }
            set
            {
                if (_placeCode != value)
                    _placeCode = value;

                RaisePropertyChanged("PlaceCode");
            }
        }
        /// <summary>
        /// Короткое название.
        /// </summary>
        public string AnsiName
        {
            get { return _ansiName; }
            set
            {
                if (_ansiName != value)
                    _ansiName = value;

                RaisePropertyChanged("AnsiName");
            }
        }
        /// <summary>
        /// Название рынка.
        /// </summary>
        public string PlaceName
        {
            get { return _placeName; }
            set
            {
                if (_placeName != value)
                    _placeName = value;

                RaisePropertyChanged("PlaceName");
            }
        }
        /// <summary>
        /// Описание типа сделки.
        /// </summary>
        public string TypeDescr
        {
            get { return _typeDescr; }
            set
            {
                if (_typeDescr != value)
                    _typeDescr = value;

                RaisePropertyChanged("TypeDescr");
            }
        }

        #endregion

        #region event PropertyChangedEventHandler

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}
